package cn.nubia.admin.common.mybatis.bean;

import java.io.Serializable;
import java.util.List;

public  class QueryParam implements Serializable{
        /**
         * 对象的属性名
         */
        public String fieldName;
        /**
         * 参数对象
         */
        public Object value;
        /**
         * 类型,1:Between  2:相等 3:like 4:in 5:大于 6:小于
         */
        public int type;

        public List<Object> subQueryData;

        public QueryParam(String fieldName, Object value, int type) {
            this.fieldName = fieldName;
            this.value = value;
            this.type = type;
        }

        public QueryParam(String fieldName, Object value, int type,  List<Object> subQueryData) {
            this.fieldName = fieldName;
            this.value = value;
            this.type = type;
            this.subQueryData = subQueryData;
        }

        public String getExpression() {
            switch (type) {
                case Query.PARAM_EQ :
                    return "=";
                case Query.PARAM_NOT_EQ :
                    return "!=";
                case Query.PARAM_GT:
                    return ">";
                case Query.PARAM_LT:
                    return "<";
                case Query.PARAM_LIKE:
                    return " like ";
                case Query.PARAM_BETWEEN:
                    return " between ";
                case Query.PARAM_IN:
                    return " in ";
                case Query.PARAM_SUB_QUERY_IN:
                    return " in ";
                case Query.PARAM_SUB_QUERY_LIKE:
                    return " like ";
                case Query.PARAM_NOT_IN:
                    return " not in ";

            }
            return "=";
        }

    }